<extend name="Extends/base" />
<block name="title">获取手机设备码</block>
<block name="css">
</block>
<block name="body_style">class="bgc-fff"</block>
<block name="body">
    <div class="c-main facility">
        <div class="facility-input">
            <input type="text" placeholder="请输入手机设备码">
        </div>
        <div>
            <a href="javascript:;" class="facility-affirm">提交</a>
        </div>
        <div class="facility-btn">
            <a href="iphoneLead.html" class="ios-btn">IOS获取设备码方法</a>
            <a href="androidLead.html" class="android-btn">android获取设备码方法</a>
        </div>
    </div>
</block>
<block name="js">
    <script type="text/javascript" src="__APPS__/js/api.js?v={:C('JS_CSS_VERSION')}"></script>
    <script type="text/javascript">
	    function setCookie(name,value)
{
var Days = 365;
var exp = new Date();
exp.setTime(exp.getTime() + Days*24*60*60*1000);
document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}

function getCookie(name)
{
var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
if(arr=document.cookie.match(reg))
return unescape(arr[2]);
else
return null;
}
		$(function(){
			var userDeviceCode=getCookie('user_device_code');
			if(userDeviceCode && userDeviceCode!=null && userDeviceCode.length>0){
				$(".facility-input input").val(userDeviceCode);
			}
		});
        $('.facility-affirm').on("click", function() {
            doSaveDeviceCode($(".facility-input input").val(),function(data){
                if(data.Code==10000 && data.Result && data.Result.url.length>0){
					setCookie('user_device_code',$(".facility-input input").val());
                    location.href=data.Result.url;
                }else
                    $.toast(data.Message);
            });
        });
    </script>
</block>